// pages/My/Collection/Collection.js
var url = wx.getStorageSync('url')
var shopid = wx.getStorageSync('shopid')
var userId = wx.getStorageSync('userId')
var openid = wx.getStorageSync('openid')
var time_ss = wx.getStorageSync('time_ss')

Page({

  /**
   * 页面的初始数据
   */
  data: {

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var shopid = wx.getStorageSync('shopid')
    var userId = wx.getStorageSync('userId')
    var openid = wx.getStorageSync('openid')
    var time_ss = wx.getStorageSync('time_ss')

    var that = this
      wx.request({
        url: url + 'gateWare/likeList',
        data: {
          "list": false,
          "nodeId": "kdslfw",
          "platform": 2,
          "privId": "default",
          "resId": "default",
          "sendTime": time_ss,
          "seq": 1,
          "shopId": shopid,
          "source": 11,
          "sysVer": "1.0.0",
          "token": "kdsjfoewi12ijsldks",
          "type": 1,
          "userId": userId,
          "userType": 1,
          "content": {
            "userId": userId
          }
        },
        method: "POST",
        header: { "Content-Type": "application/JSON" },
        success: function (e) {
          var data = e.data.content
          that.setData({
            data_s:data
          })
        }
      })
    
  },
// 删除
  sanchu:function(e){
    var shopid = wx.getStorageSync('shopid')
    var userId = wx.getStorageSync('userId')
    var openid = wx.getStorageSync('openid')
    var time_ss = wx.getStorageSync('time_ss')
    var that = this
    var activityId = e.currentTarget.dataset.activityid
    var wareId = e.currentTarget.dataset.wareid
    wx.request({
      url: url + 'getUser/delCollect',
      data: {
        "list": false,
        "nodeId": "kdslfw",
        "platform": 2,
        "privId": "default",
        "resId": "default",
        "sendTime": time_ss,
        "seq": 1,
        "shopId": shopid,
        "source": 11,
        "sysVer": "1.0.0",
        "sysCode": "0902",
        "token": "",
        "type": 1,
        "userId": userId,
        "userType": 1,
        "content": {
          "url": wareId + ',' + activityId,
        }
      },
      method: "POST",
      header: { "Content-Type": "application/JSON" },
      success: function (e) {
        var i = e.data.result.desc
        wx.showModal({
          title: '提示',
          content: '删除'+i,
          showCancel:false,
          success(res) {
            if (res.confirm) {
              wx.request({
                url: url + 'gateWare/likeList',
                data: {
                  "list": false,
                  "nodeId": "kdslfw",
                  "platform": 2,
                  "privId": "default",
                  "resId": "default",
                  "sendTime": time_ss,
                  "seq": 1,
                  "shopId": shopid,
                  "source": 11,
                  "sysVer": "1.0.0",
                  "token": "kdsjfoewi12ijsldks",
                  "type": 1,
                  "userId": userId,
                  "userType": 1,
                  "content": {
                    "userId": userId
                  }
                },
                method: "POST",
                header: { "Content-Type": "application/JSON" },
                success: function (e) {
                  var data = e.data.content
                  that.setData({
                    data_s: data
                  })
                }
              })
            } 
          }
        })
      }
    })
  },
  goto_details:function(e){
    var activityId = e.currentTarget.dataset.activityid
    var wareId = e.currentTarget.dataset.wareid
    var tag = e.currentTarget.dataset.tag
    if(tag == 1){
      wx.navigateTo({
        url: '../../index/MeteorFall/Star_details/Star_details?wareId=' + wareId + '&activityId=' + activityId,
      })
    }
    if (tag == 2) {
      wx.navigateTo({
        url: '../../index/BeautyKilling/kill_details/kill_details?wareId=' + wareId + '&activityId=' + activityId,
      })
    }
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})